using System;
using System.Collections.Generic;
using System.Text;

using Presentation.Contracts;
using Task.Contracts;
using Task;
using DataAccess;
using Globals;

namespace Presentation
	{
	public sealed class AddCommentPresenter
		{
		#region Members

		/// <summary>
		/// Instance of view.
		/// </summary>
		private IAddCommentView view;

		/// <summary>
		/// Simple galleryTask.
		/// </summary>
		private IForumTask task;

		#endregion Members

		#region Construction/Finalization

		/// <summary>
		/// Initializes a new instance of the <see cref="AddForumPresenter"/> class.
		/// </summary>
		/// <param name="view">The view.</param>
		public AddCommentPresenter(IAddCommentView view)
			{
			this.view = view;
			task = new ForumTask();
			}

		#endregion Construction/Finalization

		#region Public Methods

		/// <summary>
		/// Initializes view.
		/// </summary>
		public void Initialize()
			{
			if (view.ReplyID > 0)
				{
				NHibernateDao<DataAccess.comment, int> sampleCommentFactory = new NHibernateDao<comment, int>();
				comment tmp = sampleCommentFactory.GetById(view.ReplyID, false);
				if (tmp != null)
					{
					view.ReplyContent = tmp.contents;
					}
				}
			}

		/// <summary>
		/// Adds the new forum.

		public void AddComment()
			{
			string comentContentTmp="";
			if (view.ReplyID > 0)
				{
				comentContentTmp += "Cytowany tekst:<br><table><tr bgcolor=\"pink\"><td><h6>" + view.ReplyContent + "</h6></td></tr></table><br><br>";
				}
			comentContentTmp += view.CommentContent;
			comment cmn = new comment();
			cmn.contents = comentContentTmp;
			cmn.date = DateTime.Now;
			task.AddComment(view.ForumID, view.LoggedUserID, cmn, view.ParentCommentID);
			}

		#endregion Public Methods

		#region Private Methods

		/// <summary>
		/// Gets the forum object from view.
		/// </summary>
		/// <returns></returns>
		
		#endregion Private Methods
		}
	}
